#ifndef MAP_UTILS_H
#define MAP_UTILS_H

#include <stdint.h>

#include "hash_map.h"

#define LINE_MAX 1024
#define STR_KEY_MAX_LEN 1024
#define MAP_CAPACTIY 1 << 16

#define SRC_MAP_PATH ".map_src"
#define DST_MAP_PATH ".map_dst"
#define SPORT_MAP_PATH ".map_sport"
#define DPORT_MAP_PATH ".map_dport"
#define PROTO_MAP_PATH ".map_proto"
#define ACTION_MAP_PATH ".map_action"

uint32_t str_hash(void* key);
int str_equal_f(void* k1, void* k2);
uint32_t int_hash(void* key);
int int_equal_f(void* k1, void* k2);

int map_put_str(hash_map* map, const char* key, uint32_t value);
int map_put_int(hash_map* map, uint32_t key, uint32_t value);
int map_put_int_xor(hash_map* map, uint32_t xkey, uint32_t xval);
void map_int_xor_for_each(hash_map* map, uint32_t xval);
int map_put_str_xor(hash_map* map, char* xkey, uint32_t xval);
void map_str_xor_for_each(hash_map* map, uint32_t xval);

int load_str_map(hash_map* map, const char* cfg_file);
int save_str_map(hash_map* map, const char* cfg_file);
int load_int_map(hash_map* map, const char* cfg_file);
int save_int_map(hash_map* map, const char* cfg_file);

void print_str_map(hash_map* map, const char* reason);
void print_int_map(hash_map* map, const char* reason);
#endif // MAP_UTILS_H